import Cookies from "js-cookie";
export const changeTheme = () => {
  const theme = Cookies.get("protal-theme");
  console.log("theme:", theme);
  var styleList = [
    {
      id: "E_elementTheme",
      url: `/element-theme/${theme}/index.css?t=${new Date().getTime()}`,
    },
    {
      id: "E_auiTheme",
      url: `/element-theme/${theme}/aui.css?t=${new Date().getTime()}`,
    },
  ];
  for (var i = 0; i < styleList.length; i++) {
    var el = document.querySelector(`#${styleList[i].id}`);
    if (el) {
      el.href = styleList[i].url;
      continue;
    }
    el = document.createElement("link");
    el.id = styleList[i].id;
    el.href = styleList[i].url;
    el.rel = "stylesheet";
    document.querySelector("head").appendChild(el);
  }
};
